package Day35.map;

import java.util.HashMap;

public class HashMapDemo {
    public static void main(String[] args) {
        //创建Map集合对象
        HashMap<String,String> map = new HashMap<String,String>();
        //向Map集合添加数据
        map.put("key1","val1");
        map.put("key2","val2");
        map.put("key3","val3");
        map.put("key1","val6");//替换已有的元素？没有加进去?
        System.out.println(map);
        //通过key获得对应的value
        String key2 = map.get("key2");
        System.out.println(key2);
        //根据key从Map集合中移除一个元素
        map.remove("key2");
        System.out.println(map);
        System.out.println(map.size());
    }
}
